/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from 'react';
import { Table } from 'antd';
import { noop } from 'lodash';

const TemCommonTable = (props: any) => {
  const { columns, dataSource, onChange, pagination, rowKey } = props;

  return (
    <Table
      rowKey={rowKey}
      columns={columns.map((item: any) => ({
        ...item,
        align: 'center' as 'center',
      }))}
      dataSource={dataSource}
      onChange={onChange}
      style={{ marginTop: 20 }}
      scroll={{ x: 1200 }}
      pagination={{
        hideOnSinglePage: true,
        showSizeChanger: false,
        pageSize: 15,
        showTotal: (total) => `共 ${total} 条`,
        ...pagination,
      }}
    />
  );
};

TemCommonTable.defaultProps = {
  columns: [],
  dataSource: [],
  onChange: noop,
  pagination: {},
  rowKey: 'id',
};

export default TemCommonTable;
